<p>
  Here you can see the details of incoming and outgoing calls.
</p>

<form>
  <p>
    Search: <%= text_field_tag :search, @search, :size => 80, :class => (@search.present? ? 'highlighted' : '') %>
  </p>

  <div><%= page_entries_info @logs, :entry_name => 'call log' -%></div>
  <%= will_paginate @logs, :param_name => 'page' -%>

  <% if @logs.present? %>
    <br />

    <table class="table">
      <tr>
        <th>ID</th>
        <th>Started</th>
        <th>Finished</th>
        <th>Duration</th>
        <th>Caller ID</th>
        <th>Direction</th>
        <th>Channel</th>
        <th>Application</th>
        <th>State</th>
        <th></th>
      </tr>

      <% @logs.each do |log| %>
        <tr>
          <td><%= log.id %></td>
          <td><%= raw time_ago log.created_at %></td>
          <td><%= raw time_ago log.finished_at %></td>
          <td><%= distance_of_time_in_words(log.finished_at, log.created_at, true) if log.finished_at %></td>
          <% if log.address.present? %>
            <td><%= link_to log.address, call_logs_path(:search => "caller:#{log.address}") %></td>
          <% else %>
            <td><%= log.address %></td>
          <% end %>
          <td><%= log.direction %></td>
          <td><%= log.channel.try(:name) %></td>
          <td><%= log.application.try(:name) %></td>
          <td><%= log.state %></td>
          <td><%= link_to 'view details', call_log_path(log) %></td>
        </tr>
      <% end %>
    </table>

    <br />

    <div><%= page_entries_info @logs, :entry_name => 'call log' -%></div>
    <%= will_paginate @logs, :param_name => 'page' -%>
  <% end %>
</form>

<br />

